package com.wubo.common.jdbc;

import java.io.InputStream;
import java.util.Properties;

/**
 * 
 * @author WuBo
 * @CreateDate 2012-4-11 下午03:39:03
 */
public class DBConfig {
	private String driver;
	private String url;
	private String username;
	private String password;
	
	public DBConfig(String config){
		InputStream is = null;
		Properties prop = null;
		try{
			prop = new Properties();
			is = DBConfig.class.getClassLoader().getResourceAsStream(config);
			prop.load(is);
			
			driver = prop.getProperty("jdbc.driver");
			url = prop.getProperty("jdbc.url");
			username = prop.getProperty("jdbc.username");
			password = prop.getProperty("jdbc.password");
		}catch(Exception e){
			throw new ExceptionInInitializerError(e);
		}finally{
			if(is != null){try{is.close();}catch(Exception e){}};
			prop = null;
		}
	}

	public String getDriver() {
		return driver;
	}

	public String getUrl() {
		return url;
	}

	public String getUsername() {
		return username;
	}

	public String getPassword() {
		return password;
	}
	
}
